package cn.jsj.machine.dao;

import cn.jsj.machine.pojo.CUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.hibernate.validator.constraints.Length;
import org.springframework.stereotype.Repository;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@Validated
@Repository
public interface IUserDao {

    @Results(id = "toUser", value = {
            @Result(id = true,property = "userID",column = "user_id"),
            @Result(property = "userAccount", column = "account"),
            @Result(property = "userType",column = "user_type"),
            @Result(property = "userName",column = "user_name")
    })
    @Select("select user_id, user_type, user_name, account from tb_user where account = #{userAccount} and password = #{password} limit 1")
    CUser getOneUserByAccountAdnPassword(@Param("userAccount")@NotNull@Min(value = 1) Integer userAccount, @Param("password")@NotBlank@Length(max = 20) String password);

}
